package model;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

import controller.MisterJumpController;

public class Bullet extends Thing implements Item {
	
	private double ay = .001;
	private double vx, vy;
	private double startX, startY;
	
	public Bullet(double cStartX, double cStartY, double cAngle) throws SlickException {
		super(cStartX, cStartY);
		
		image = new Image("data/kugel.png");
		
		double faktor = 0.03; //TODO
		vx = Math.sin(cAngle) * faktor;
		vy = Math.cos(cAngle) * faktor;
		
		width = .03;
		height = .03;
	}
	
	public Type getType() {
		return Type.KUGEL;
	}

	@Override
	public void act() 
	{
		vy -= ay;
		setX(getX() + vx);
		setY(getY() + vy);
		
		Item[] things = Wrapper.getInstance().holeSichtfenster();
		for (Item thing : things)
		{
			if (thing instanceof Monster)
			{
				if (MisterJumpController.collisionDetected(getX(), getY(), getWidth(), getHeight(), thing.getX(), thing.getY(), thing.getWidth(), thing.getHeight()))
				{
					((Monster) thing).kill();
				}
			}
		}
		// TODO Auto-generated method stub
		
	}
	
	public double getStartX(){
		return startX;
	}
	
	public double getStartY(){
		return startY;
	}
	

}